.TH std::experimental::filesystem::path::stem 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::experimental::filesystem::path::stem \- std::experimental::filesystem::path::stem

.SH Synopsis
   path stem() const;  (filesystem TS)

   Returns the filename identified by the path stripped of its extension.

   Returns the substring from the beginning of filename() up to and not including the
   last period (.) character.

   If the filename is one of the special filesystem components dot or dot-dot, or if it
   has no periods, the function returns the entire filename().

.SH Parameters

   \fI(none)\fP

.SH Return value

   The stem of the filename identified by the path.

.SH Exceptions

   May throw implementation-defined exceptions.

.SH Example


// Run this code

 #include <experimental/filesystem>
 #include <iostream>
 namespace fs = std::experimental::filesystem;

 int main()
 {
     std::cout << fs::path("/foo/bar.txt").stem() << '\\n'
               << fs::path("/foo/.bar").stem() << '\\n';

     for (fs::path p = "foo.bar.baz.tar"; !p.extension().empty(); p = p.stem())
         std::cout << p.extension() << '\\n';
 }

.SH Output:

 "bar"
 ""
 ".tar"
 ".baz"
 ".bar"

.SH See also

   filename  returns the filename path component
             \fI(public member function)\fP
   extension returns the file extension path component
             \fI(public member function)\fP

.SH Category:
     * Noindexed pages
